from selenium.webdriver.common.by import By
import time


class LoginOperation:

    def login(self,driver,name,pwd):

        driver.find_element(By.XPATH, '//input[@id="username"]').send_keys(name)
        # 输入账号
        driver.find_element(By.XPATH, '//input[@id="password"]').send_keys(pwd)
        # 输入密码
        driver.find_element(By.XPATH, '//button[@id="login_btn"]').click()
        # 点击登录按钮
        time.sleep(3)

    def getSuccessResult(self,driver):

        return driver.find_element(By.XPATH,'//*[@id="logo"]/a').text

    def getUserNameErrorResult(self,driver):

        return driver.find_element(By.XPATH,"//div[@class='login-center1']/form/div[1]/span[1]").text

    def getPwdErrorResult(self,driver):

        return driver.find_element(By.XPATH,"//div[@class='login-center1']/form/div[2]/span[1]").text